<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <bodys>
    <script>
      var arr = [1, 5, 1, 4, 5, 6, 5, 1, 2];
      // arr = arr.filter((item, index) => arr.indexOf(item) === index);
      console.log(arr);

      function de_weight(arr) {
        let newArr = [];
        for (var i = 0; i < arr.length; i++) {
          if (arr.indexOf(arr[i], i + 1) === -1) {
            newArr.push(arr[i]);
          }
        }
        return newArr;
      }
      console.log(de_weight(arr));
    </script>
  </bodys>
</html>
